

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="mode" />
        <title>${Inter.printOut('Projects',session.language)}</title>
    </head>
    <body>
        <div class="undernav">
          <%
          def a = session.access
          a.refresh()
          %>
          <g:if test="${(!session.mode.equalsIgnoreCase('budget')) || (session.mode.equalsIgnoreCase('budget') && !a.isBudgetLocked())}">
            <span class="menuButton"><g:link class="createProject" action="create">${Inter.printOut('New Project',session.language)}</g:link></span>
          </g:if>
           

            <!-- This is the help button. -->
            <%  def help = Help.findByNameAndLanguage("project_list", session.language)
            def helplink = createLink(action:'show', controller:'help', id: help.id )%>
            <a href="#" onClick="MyWindow=window.open('${helplink}','Help','width=350,height=450'); return false;">${Inter.printOut('Help',session.language)}</a>
            <!-- This is the end of the help button. -->

        </div>
      
        <div class="body" style="width:98%">
            
            <h1>${Inter.printOut('Projects',session.language)}</h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <div class="list">
                <table style="table-layout: fixed">
                    <thead>
                        <tr>
                   	        <g:sortableColumn property="activityId" title="${Inter.printOut('Activity Id',session.language)}" />
                        
                   	        <g:sortableColumn property="name" title="${Inter.printOut('name',session.language)}" />
                        
                   	        <g:sortableColumn property="description" title="${Inter.printOut('Description',session.language)}" />
                               <!-- <g:sortableColumn property="area" title="${Inter.printOut('Area',session.language)}" />-->
                                <!-- <th>Area</th>-->
                                <g:sortableColumn property="startDate" title="${Inter.printOut('Start Date',session.language)}" />
                   	        <g:sortableColumn property="endDate" title="${Inter.printOut('End Date',session.language)}" />
                                <th>Status</th>
                                <th>${Inter.printOut('Current Balance',session.language)}</th>
                                <th>${Inter.printOut('Incoming Balance',session.language)}</th>
                        
                        </tr>
                    </thead>
                    <tbody>
                    <g:each in="${projectInstanceList}" status="i" var="projectInstance">
                      <g:if test="${ModeAccess.isAvailableInCurrentMode(session.mode,projectInstance.mode)}">
                        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                        
                            <td>
                                <g:link action="show" id="${projectInstance.id}">
                                 ${fieldValue(bean:projectInstance, field:'activityId')}
                                </g:link>
                            </td>
                        
                            <td>
                                <g:link action="show" id="${projectInstance.id}">
                                  ${fieldValue(bean:projectInstance, field:'name')}
                                </g:link>
                            </td>
                        
                            <td>
                               <g:link action="show" id="${projectInstance.id}">
                                  ${fieldValue(bean:projectInstance, field:'description')}
                               </g:link>
                            </td>
                            <!--
                            <td>
                                 <g:link action="show" id="${projectInstance.id}">
                                   ${fieldValue(bean:projectInstance, field:'area')}
                                 </g:link>
                            </td>
                            -->
                            <td>
                               <g:formatDate date="${projectInstance.startDate}" format="yyyy-MM-dd"/>
                            </td>

                            <td>
                              <g:formatDate date="${projectInstance.endDate}" format="yyyy-MM-dd"/>
                            </td>

                            <td>
                                ${Inter.printOut(projectInstance.calcStatus(),session.language)}
                            </td>
                            <td>
                             
                                ${projectInstance.calcCurrentBalance()}
                              
                            </td>
                            <td> --
                              <!-- ${projectInstance.currentBudget().calcBalance()} -->
                            </td>                        
                        </tr>
                       </g:if> 
                      
                    </g:each>
                    </tbody>
                </table>
            </div>
            <div class="paginateButtons">
                <g:paginate total="${projectInstanceTotal}" />
            </div>
             <div>
                Total Balance : ${balance}
            </div>
        </div>
       
    </body>
</html>
